package lyj.springcloud.feign.impl;

import feign.hystrix.FallbackFactory;
import lyj.springcloud.feign.OrderFeign;
import org.springframework.stereotype.Component;

/**
 * 通过配置注解@FeignClient的fallbackFactory属性，实现服务降级兜底方法
 *
 */
@Component
public class OrderFeignFactory implements FallbackFactory {
    @Override
    public Object create(Throwable cause) {
        return new OrderFeign() {
            @Override
            public String paymentok(String id) {
                return "paymentok 对方服务异常";
            }

            @Override
            public String paymentTimeout(String id) {
                return "对方服务超时";
            }
        };
    }
}
